package api;

import com.alibaba.fastjson.JSONObject;
import org.example.common.OrderService;
import org.example.model.Order;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by Sinotn
 *
 * @Author: libin
 * @CreateTime: 2020-06-20 13:35
 * @Description:
 */
public class Consumer {

    public static void main(String[] args) throws Exception {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:consumer.xml");
        context.start();
        OrderService service = (OrderService)context.getBean("orderService"); // 获取远程服务代理
        Order order = service.getOrderById(1L); // 执行远程方法
        System.out.println(JSONObject.toJSONString(order)); // 显示调用结果
    }
}
